package com.kitty.game.rank.model.record;

import lombok.Getter;
import lombok.Setter;

/**装备排行榜记录*/
@Setter
@Getter
public class EquipRankRecord extends RankRecord {
    private String gid;//装备id
    private String name;//装备名称
    private short upgradeLevlel;//改造等级
    private String roleName;//角色名称
    private int perfect;//完美度
    private short level;//等级

    public EquipRankRecord() {}

    public EquipRankRecord(String gid, String name, short upgradeLevlel, String roleName, int perfect, short level) {
        this.gid = gid;
        this.name = name;
        this.upgradeLevlel = upgradeLevlel;
        this.roleName = roleName;
        this.perfect = perfect;
        this.level = level;
    }

    @Override
    public int compareTo(RankRecord o) {
        /**先按改造等级从大到小，再按完美度从大到小排序*/
        EquipRankRecord other = (EquipRankRecord)o;
        if (upgradeLevlel != other.getUpgradeLevlel()) {
            return upgradeLevlel > other.getUpgradeLevlel() ? -1 : 1;
        }

        if (perfect != other.getPerfect()) {
            return perfect > other.getPerfect() ? -1 : 1;
        }

        /**都一样时，就按gid排序吧，保证不是同一个装备就好了*/
        return gid.compareTo(other.getGid());
    }
}
